<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="用户名称" prop="userName">
        <el-input v-model="queryParams.userName" class="input-w-180" placeholder="请输入用户名称" clearable
                  @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="用户姓名" prop="userName">
        <el-input v-model="queryParams.nickName" placeholder="请输入用户名称" clearable class="input-w-180"
                  @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="上岗证" prop="postsNumber">
        <el-input v-model="queryParams.postsNumber" placeholder="请输入用户名称" clearable class="input-w-180"
                  @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="社区" prop="community">
        <el-input v-model="queryParams.params.community" placeholder="请输入社区" clearable class="input-w-180"
                  @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="手机号码" prop="phonenumber">
        <el-input v-model="queryParams.phonenumber" placeholder="请输入手机号码" clearable class="input-w-180"
                  @keyup.enter.native="handleQuery"/>
      </el-form-item>
<!--      <el-form-item label="初复训" prop="reservedOne">-->
<!--        <el-select v-model="queryParams.params.reservedOne" placeholder="初复训" clearable class="input-w-180">-->
<!--          <el-option :key="0" label="初训" :value="0"/>-->
<!--          <el-option :key="1" label="复训" :value="1"/>-->
<!--        </el-select>-->
<!--      </el-form-item>-->
      <el-form-item label="状态" prop="status">
        <el-select v-model="queryParams.status" placeholder="用户状态" clearable class="input-w-180">
          <el-option v-for="dict in dict.type.sys_normal_disable" :key="dict.value" :label="dict.label"
                     :value="dict.value"/>
        </el-select>
      </el-form-item>
      <el-form-item label="创建时间">
        <el-date-picker v-model="dateRange" style="width: 240px" value-format="yyyy-MM-dd" type="daterange"
                        range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
      </el-form-item>
      <el-form-item label="报名班">
        <!-- 报名班 -->
        <el-select v-model="queryParams.params.classId" placeholder="报名班" clearable class="input-w-180">
          <el-option v-for="clazz in classList" :key="clazz.id" :label="clazz.name" :value="clazz.id"/>
        </el-select>
        <el-radio-group v-if="isNotNull(queryParams.params.classId) && !isEmptyStr(queryParams.params.classId)"
                        v-model="queryParams.params.apply" size="mini">
          <el-radio-button :label="0">未报名</el-radio-button>
          <el-radio-button :label="1">报名</el-radio-button>
        </el-radio-group>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
                   v-hasPermi="['system:user:add']">新增
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
                   v-hasPermi="['system:user:remove']">删除
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="info" plain icon="el-icon-upload2" size="mini" @click="handleImport"
                   v-hasPermi="['system:user:import']">导入
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
                   v-hasPermi="['system:user:export']">导出
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="userList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="50" align="center"/>
      <el-table-column label="头像" align="center" prop="name" width="50">
        <template slot-scope="scope">
          <viewer v-if="scope.row.avatar != undefined && scope.row.avatar != null && scope.row.avatar != ''">
            <el-avatar shape="square" size="large" :src="scope.row.avatar"></el-avatar>
          </viewer>
          <el-avatar v-else size="large" src=""></el-avatar>
        </template>
      </el-table-column>
      <el-table-column label="账户名称" align="center" prop="userName" :show-overflow-tooltip="true" width="100"/>
      <el-table-column label="姓名" align="center" prop="nickName" :show-overflow-tooltip="true" width="100"/>
      <el-table-column label="上岗证" align="center" prop="postsNumber" :show-overflow-tooltip="true" width="150"/>
      <!--      <el-table-column label="部门" align="center" prop="dept.deptName" :show-overflow-tooltip="true"/>-->
<!--      <el-table-column label="初复训" align="center">-->
<!--        <template slot-scope="scope">-->
<!--          <el-tag v-if="scope.row.userInfo.reservedOne == 1">复训</el-tag>-->
<!--          <el-tag v-else type="success">初训</el-tag>-->
<!--        </template>-->
<!--      </el-table-column>-->
      <el-table-column label="社区" align="center" prop="userInfo.community"/>
      <el-table-column label="执业类别" align="center" prop="userInfo.practiceType"/>
      <el-table-column label="执业范围" align="center" prop="userInfo.practiceRange"/>
      <el-table-column label="所在科室/岗位" align="center" prop="userInfo.posts"/>
      <el-table-column label="联系方式" align="center" prop="phonenumber"/>
      <el-table-column label="参加初训年份" align="center" prop="userInfo.initialTraining"/>
      <el-table-column label="出生年月" align="center" prop="identity">
        <template slot-scope="scope" v-if="scope.row.userId !== 1">
          {{ parseTime(scope.row.birthday, '{y}-{m}-{d}') }}
        </template>
      </el-table-column>
      <el-table-column label="创建时间" align="center" prop="createTime">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" width="180" class-name="small-padding fixed-width">
        <template slot-scope="scope" v-if="scope.row.userId !== 1">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
                     v-hasPermi="['system:user:edit']">修改
          </el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
                     v-hasPermi="['system:user:remove']">删除
          </el-button>
          <el-button size="mini" type="text" icon="el-icon-view" @click="openStudyCount(scope.row)"
                     v-hasPermi="['system:user:remove']">学习记录
          </el-button>
        </template>
      </el-table-column>
      <el-table-column label="培训记录" width="50" type="expand">
        <template slot-scope="scope">
          <!-- 学生报名记录 -->
          <el-table :data="scope.row.studyRecords" style="background: #87CEFA" :row-class-name="studyRecordsClassName"
                    border max-height="250" size="mini">
            <el-table-column label="培训班" align="center" prop="trainingClass.name"/>
            <el-table-column label="教师" align="center" prop="trainingClass.teacher"/>
            <el-table-column label="颁证时间" align="center" prop="cert.issuanceDate"/>
            <el-table-column label="证书编号" align="center" prop="cert.certNo"/>
            <el-table-column label="报名时间" align="center" prop="certTime">
              <template slot-scope="scope1">
                {{ parseTime(scope1.row.createTime, '{y}-{m}-{d}') }}
              </template>
            </el-table-column>
            <el-table-column label="状态" align="center" prop="status">
              <template slot-scope="scope1">
                <dict-tag :options="dict.type.pv_study_record_status" :value="scope1.row.status"/>
              </template>
            </el-table-column>
            <el-table-column label="操作" align="center" width="130" class-name="small-padding fixed-width">
              <template slot-scope="scope1">
                <el-button v-if="scope1.row.status == '0'" size="mini" type="text" icon="el-icon-magic-stick"
                           @click="completeCourse(scope1.row.id)">结业
                </el-button>
                <el-button size="mini" type="text" icon="el-icon-delete" @click="recordHandleDelete(scope1.row)">删除
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
                @pagination="getList"/>

    <!-- 添加或修改用户配置对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-row :gutter="20">
          <el-col :span="10" :xs="20">
            <el-form-item label="头像上传" prop="avatar">
              <el-upload class="avatar-uploader" action="#" :on-change="uploadPhoto" :auto-upload="false"
                         :show-file-list="false">
                <img v-if="form.avatar" :src="form.avatar" class="avatar">
                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
              </el-upload>
            </el-form-item>
          </el-col>
          <el-col :span="4" :xs="24">
            <el-form-item v-if="form.userId == undefined" label="账户名称" style="width: 240px" prop="userName">
              <el-input v-model="form.userName" placeholder="登录用" style="width: 240px" maxlength="30" clearable/>
            </el-form-item>
            <el-form-item label="姓名" prop="nickName">
              <el-input v-model="form.nickName" style="width: 240px" placeholder="请输入用户昵称" maxlength="30"
                        clearable/>
            </el-form-item>
            <el-form-item label="上岗证编号">
              <el-input v-model="form.postsNumber" style="width: 240px" placeholder="请输入用户上岗证编号"
                        maxlength="30" clearable/>
            </el-form-item>
            <el-form-item label="手机号码" prop="phonenumber">
              <el-input v-model="form.phonenumber" placeholder="请输入手机号码" style="width: 240px" maxlength="11"
                        clearable/>
            </el-form-item>
            <el-form-item label="出生年月" prop="birthday">
              <el-date-picker v-model="form.birthday" value-format="yyyy-MM-dd" type="date" placeholder="选择日期"
                              clearable></el-date-picker>
            </el-form-item>
            <el-form-item label="社区" prop="community">
              <el-input @input="$forceUpdate()" v-model="form.userInfo.community" placeholder="请输入社区"
                        style="width: 240px" clearable/>
            </el-form-item>
            <el-form-item label="执业类别" prop="practiceType">
              <el-input @input="$forceUpdate()" v-model="form.userInfo.practiceType" placeholder="请输入执业类别"
                        style="width: 240px" clearable/>
            </el-form-item>
            <el-form-item label="执业范围" prop="practiceRange">
              <el-input @input="$forceUpdate()" v-model="form.userInfo.practiceRange" placeholder="请输入执业范围"
                        style="width: 240px" clearable/>
            </el-form-item>
            <el-form-item label="所在科室/岗位" prop="posts">
              <el-input @input="$forceUpdate()" v-model="form.userInfo.posts" placeholder="请输入所在科室/岗位"
                        style="width: 240px" clearable/>
            </el-form-item>
            <el-form-item label="参加初训年份" prop="initialTraining">
              <el-input @input="$forceUpdate()" v-model="form.userInfo.initialTraining" placeholder="请输入参数初训年份"
                        style="width: 240px" clearable/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 用户导入对话框 -->
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="600px" append-to-body>
      <center>
        <el-upload v-loading="upload.loading" element-loading-text="需要比对用户历史记录，请稍后..." ref="upload"
                   :limit="1" accept=".xlsx,.xls" :headers="upload.headers"
                   :action="upload.url" :disabled="upload.isUploading"
                   :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
          <i class="el-icon-upload"></i>
          <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
          <div class="el-upload__tip text-center" slot="tip">
            <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;"
                     @click="importTemplate">下载模板
            </el-link>
            <el-descriptions :column="1" title="注意" size="small">
              <el-descriptions-item label="1">仅允许导入<span class="text-red">xls</span>、<span
                class="text-red">xlsx</span>格式文件
              </el-descriptions-item>
              <el-descriptions-item label="2"><span class="text-red">用户姓名</span>和<span
                class="text-red">上岗证编号</span>为必填项
              </el-descriptions-item>
              <el-descriptions-item label="3">先根据用户姓名和上岗证编号联合查询，新用户则新增、老用户更新信息
              </el-descriptions-item>
            </el-descriptions>
          </div>
        </el-upload>
        <div slot="footer" class="dialog-footer" style="margin-top: 20px">
          <el-button type="primary" @click="submitFileForm">确 定</el-button>
          <el-button @click="upload.open = false">取 消</el-button>
        </div>
      </center>
    </el-dialog>

    <!-- 学习记录 -->
    <el-drawer :title="study_count.stu_name" :visible.sync="study_count.open" direction="rtl"
               :before-close="drawerClose" append-to-body>
      <el-table :data="study_count.list" height="600">
        <el-table-column label="题库" align="center" prop="bank.name"/>
        <el-table-column label="学习时间" align="center" prop="createTime"/>
      </el-table>
    </el-drawer>
  </div>
</template>

<script>
import {
  listUser,
  getUser,
  addUser,
  changeUserStatus,
  deptTreeSelect, delTrueUser, updateUserInfo
} from "@/api/system/userStudent";
import {get_study_count_by_stu} from '@/api/ex/study_count'
import {copyObj, fillObj, isNotNull, isNull, isNotEmpty} from '@/utils/zzDouUtils/ObjUtil'
import {getToken} from "@/utils/auth";
import {fileUpload} from "@/api/file";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import {delStu_record, updateStu_record} from "@/api/pv/stu_record";
import {listTraining_class} from "@/api/pv/training_class";
import log from "@/views/monitor/job/log.vue";

export default {
  name: "User",
  dicts: ['sys_normal_disable', 'sys_user_sex', 'pv_study_record_status'],
  components: {Treeselect},
  data() {
    return {
      recordOpen: false,
      recordForm: {},
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 用户表格数据
      userList: null,
      // 弹出层标题
      title: "",
      // 部门树选项
      deptOptions: undefined,
      // 是否显示弹出层
      open: false,
      // 部门名称
      deptName: undefined,
      // 默认密码
      initPassword: 123456,
      // 日期范围
      dateRange: [],
      // 岗位选项
      postOptions: [],
      // 角色选项
      roleOptions: [],
      // 表单参数
      form: {
        userInfo:{},
      },
      defaultProps: {
        children: "children",
        label: "label"
      },
      // 用户导入参数
      upload: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
        // 是否禁用上传
        isUploading: false,
        loading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: {Authorization: "Bearer " + getToken()},
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/system/user/importData-student"
      },
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userName: undefined,
        phonenumber: undefined,
        status: undefined,
        deptId: undefined,
        params: {
          community:null,
          reservedOne:null,
        },
      },
      //临时对象
      recordFlag: null,
      // 表单校验
      rules: {
        userName: [
          {required: true, message: "用户名称不能为空", trigger: "blur"},
          {min: 2, max: 20, message: '用户名称长度必须介于 2 和 20 之间', trigger: 'blur'}
        ],
        nickName: [
          {required: true, message: "用户昵称不能为空", trigger: "blur"}
        ],
        postsNumber: [
          {required: true, message: "上岗证编号不能为空", trigger: "blur"}
        ],
        password: [
          {required: true, message: "用户密码不能为空", trigger: "blur"},
          {min: 5, max: 20, message: '用户密码长度必须介于 5 和 20 之间', trigger: 'blur'}
        ],
        email: [
          {
            type: "email",
            message: "请输入正确的邮箱地址",
            trigger: ["blur", "change"]
          }
        ],
        phonenumber: [
          {
            pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
            message: "请输入正确的手机号码",
            trigger: "blur"
          }
        ],
        identity: [
          {
            pattern: /^([1-6][1-9]|50)\d{4}(18|19|20)\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,
            message: "请输入正确的身份证",
            trigger: "blur"
          }
        ]
      },
      classList: [],
      study_count: {
        open: false,
        stu_name: null,
        list: [],
      }
    };
  },
  watch: {
    // 根据名称筛选部门树
    deptName(val) {
      this.$refs.tree.filter(val);
    },
  },
  created() {
    this.getList();
    this.getClassList();
    this.getDeptTree();
    this.getConfigKey("sys.user.initPassword").then(response => {
      this.initPassword = response.msg;
    });
  },
  methods: {
    isNotEmpty,
    /** 查询培训班管理列表 */
    getClassList() {
      listTraining_class({pageSize: 1000, pageNum: 1}).then(response => {
        this.classList = response.rows;
      });
    },
    /** 查询用户列表 */
    getList() {
      if (isNotNull(this.queryParams.params.classId) && isNull(this.queryParams.params.apply)) {
        this.$notify.error('请选择报名状态')
        return;
      }
      this.loading = true;
      listUser(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
        console.log(response)
          this.userList = response.rows;
          this.total = response.total;
          this.loading = false;
        }
      );
    },
    /** 查询部门下拉树结构 */
    getDeptTree() {
      deptTreeSelect().then(response => {
        this.deptOptions = response.data;
      });
    },
    // 筛选节点
    filterNode(value, data) {
      if (!value) return true;
      return data.label.indexOf(value) !== -1;
    },
    // 节点单击事件
    handleNodeClick(data) {
      this.queryParams.deptId = data.id;
      this.handleQuery();
    },
    // 用户状态修改
    handleStatusChange(row) {
      let text = row.status === "0" ? "启用" : "停用";
      this.$modal.confirm('确认要"' + text + '""' + row.userName + '"用户吗？').then(function () {
        return changeUserStatus(row.userId, row.status);
      }).then(() => {
        this.$modal.msgSuccess(text + "成功");
      }).catch(function () {
        row.status = row.status === "0" ? "1" : "0";
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        userId: undefined,
        deptId: undefined,
        userName: undefined,
        avatar: undefined,
        nickName: undefined,
        password: undefined,
        birthday: undefined,
        phonenumber: undefined,
        userInfo: {
          community: " ",//社区
          practiceRange: undefined,//执业范围
          practiceType: undefined,//执业类别
          posts: undefined,//所在科室/岗位
          initialTraining: undefined,//参加初训年份
        }
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.queryParams.deptId = undefined;
      this.$refs.tree.setCurrentKey(null);
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.userId);
      this.single = selection.length != 1;
      this.multiple = !selection.length;
    },
    // 更多操作触发
    handleCommand(command, row) {
      switch (command) {
        case "handleResetPwd":
          this.handleResetPwd(row);
          break;
        case "handleAuthRole":
          this.handleAuthRole(row);
          break;
        default:
          break;
      }
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      getUser().then(response => {
        this.postOptions = response.posts;
        this.roleOptions = response.roles;
        this.open = true;
        this.title = "添加用户";
        this.form.password = this.initPassword;
      });
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      this.form = copyObj(row);
      fillObj(this.form, row.userInfo, 'id');
      this.open = true;
      this.title = "修改用户";
    },
    /** 提交按钮 */
    submitForm: function () {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.userId != undefined) {
            updateUserInfo(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addUser(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const userIds = row.userId || this.ids;
      this.$modal.confirm('是否确认删除用户编号为"' + userIds + '"的数据项？').then(function () {
        return delTrueUser(userIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/user/export-student', {
        ...this.queryParams
      }, `公卫处方权工作人员_${new Date().getTime()}.xlsx`)
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "用户导入";
      this.upload.open = true;
    },
    /** 下载模板操作 */
    importTemplate() {
      this.download('system/user/importTemplate-student', {}, `公卫处方权工作人员数据表模板_${new Date().getTime()}.xlsx`)
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.loading = true;
      this.upload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.upload.loading = false;
      this.$refs.upload.clearFiles();
      this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", {dangerouslyUseHTMLString: true});
      this.getList();
    },
    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    },
    /** 上传头像 */
    uploadPhoto(file, fileList) {
      fileUpload(file).then(response => {
        this.form.avatar = response.msg;
        fileList.splice(0);
      });
    },
    /** 培训记录颜色 */
    studyRecordsClassName({row, rowIndex}) {
      if (rowIndex === 0) {
        return 'warning-row';
      }
    },
    openRecordEdit(row) {
      this.recordOpen = true;
      this.recordForm = {...row}
    },
    cancelRecord() {
      this.recordOpen = false;
      this.recordForm = {}
    },
    /** 删除按钮操作 */
    recordHandleDelete(row) {
      const ids = row.id;
      this.$modal.confirm('是否确认删除学员报名记录编号为"' + ids + '"的数据项？').then(function () {
        return delStu_record(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {
      });
    },
    completeCourse(id) {
      const recordForm = {id: id, status: '1'};
      updateStu_record(recordForm).then(response => {
        this.$modal.msgSuccess("结业成功");
        this.getList();
      });
    },
    recordUpdate() {
      updateStu_record(this.recordForm).then(response => {
        this.$modal.msgSuccess("修改成功");
        this.recordOpen = false;
        this.getList();
      });
    },
    /** 打开学习记录抽屉 */
    openStudyCount(row) {
      this.study_count.stu_name = row.nickName
      get_study_count_by_stu(row.userId).then(response => {
        this.study_count.list = response.rows;
        this.study_count.open = true;
      });
    },
    drawerClose(done) {
      this.study_count = {open: false, stu_name: null, list: []}
      done();
    }
  }
};
</script>

<style>
.el-table .warning-row {
  background: oldlace;
}

.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.avatar-uploader .el-upload:hover {
  border-color: #409EFF;
}

.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}

.avatar {
  width: 178px;
  height: 178px;
  display: block;
}
</style>
